package com.example.androidapp2;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

public class PopUpTarjetas extends Dialog {

	public  EditText TxtCuotas;
	public  ImageView BtnArriba;
	public ImageView BtnAbajo;
	public Button BtnAceptar;
	public Button BtnCancelar;

	public PopUpTarjetas(Context context) {
		super(context);
		this.setContentView(R.layout.pup_tarjetas);
		this.setTitle("Cuotas?");
		
		TxtCuotas = (EditText) findViewById(R.id.txtCuotas);
		BtnArriba	= (ImageView) findViewById(R.id.ibtnArriba);
		BtnAbajo	= (ImageView) findViewById(R.id.ibtnAbajo);
		BtnAceptar	= (Button) findViewById(R.id.btnAceptar);
		BtnCancelar	= (Button) findViewById(R.id.btnCancelar);
	}
	
	public void SetListenerBotonesPopUpTarjetas()
	{
		BtnArriba.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				if(!TxtCuotas.getText().toString().equals(""))
					TxtCuotas.setText(String.valueOf(Integer.parseInt(TxtCuotas.getText().toString())+1));
				else
					TxtCuotas.setText(String.valueOf(1));
			}
		});

		BtnAbajo.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				if(!TxtCuotas.getText().toString().equals(""))
					if(Integer.parseInt(TxtCuotas.getText().toString())!=1)
						TxtCuotas.setText(String.valueOf(Integer.parseInt(TxtCuotas.getText().toString())-1));
					else
						TxtCuotas.setText("");
			}
		});

		BtnAceptar.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				hide();
			}
		});

		BtnCancelar.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				hide();
			}
		});
	}

}
